﻿package mortal.game.view.ThanksGiving.panel
{
    import com.gengine.core.frame.*;
    import com.mui.controls.*;
    import extend.language.*;
    import flash.events.*;
    import mortal.common.global.*;
    import mortal.game.cache.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.view.ThanksGiving.data.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.display.*;
    import mortal.game.view.common.item.*;
    import mortal.game.view.copy.GroupTowerCopy.data.*;
    import mortal.game.view.rebate.item.*;
    import mortal.mvc.core.*;

    public class ThanksGivingDuiHuanPanel extends GSprite
    {
        protected var _mbg:GImageBitmap;
        protected var _des:GTextFiled;
        protected var _day:BitmapNumberText;
        protected var _hour:BitmapNumberText;
        protected var _min:BitmapNumberText;
        protected var _reNumDes:GTextFiled;
        protected var _reNum:GTextFiled;
        protected var _itemM:BaseItem;
        protected var _huoYuDes:GTextFiled;
        protected var _item1:BaseItem;
        protected var _item2:BaseItem;
        protected var _rewList:CellsGridSprite;
        protected var _yuanbo:GBitmap;
        protected var _gotoChangeBtn:GLoadingButton;
        protected var _gotoTanBaoBtn:GLoadingButton;
        protected var _reBtn:GLoadingButton;
        protected var _des2:GTextFiled;
        private var _secT:SecTimer;

        public function ThanksGivingDuiHuanPanel()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._mbg = UIFactory.gImageBitmap(ImagesConst.ThanksGivingDuiHuan, 0, 0, this);
            this._des = UIFactory.gTextField("" + Language.getString(71936), 35, 226, 630, 90, this, GlobalStyle.textFormatPutong.setColor(16777215));
            this._des.multiline = true;
            this._des.wordWrap = true;
            this._day = UIFactory.bitmapNumberText(153, 141, "investmentNum.png", 24, 30, -8, this, 9, 1);
            this._day.text = "00";
            this._hour = UIFactory.bitmapNumberText(207, 141, "investmentNum.png", 24, 30, -8, this, 9, 1);
            this._hour.text = "00";
            this._min = UIFactory.bitmapNumberText(278, 141, "investmentNum.png", 24, 30, -8, this, 9, 1);
            this._min.text = "00";
            this._reNumDes = UIFactory.gTextField("" + Language.getString(71937), 350, 144, 100, 20, this, GlobalStyle.textFormatPutong.setColor(16777215).setSize(13));
            this._reNum = UIFactory.gTextField("12346", 417, 144, 100, 20, this, GlobalStyle.textFormatPutong.setColor(16777215).setSize(13));
            this._itemM = UIFactory.getUICompoment(BaseItem);
            this._itemM.setItemStyle(ItemStyleConst.Small, ImagesConst.PackItemBg, 2, 2);
            UIFactory.setObjAttri(this._itemM, 312, 216, -1, -1, this);
            this._huoYuDes = UIFactory.gTextField("" + Language.getString(71938), 357, 227, 100, 20, this, GlobalStyle.textFormatChen);
            this._item1 = UIFactory.getUICompoment(BaseItem);
            this._item1.setItemStyle(ItemStyleConst.Big, ImagesConst.ShopItemBg, 6, 6);
            UIFactory.setObjAttri(this._item1, 38, 397, -1, -1, this);
            this._item2 = UIFactory.getUICompoment(BaseItem);
            this._item2.setItemStyle(ItemStyleConst.Big, ImagesConst.ShopItemBg, 6, 6);
            UIFactory.setObjAttri(this._item2, 577, 397, -1, -1, this);
            this._rewList = UIFactory.getUICompoment(CellsGridSprite);
            this._rewList.colNum = 9;
            this._rewList.vCellWid = 45;
            this._rewList.hCellWid = 45;
            this._rewList.genCellFun = this.genItem;
            this._rewList.genCells(18);
            this._rewList.x = 142;
            this._rewList.y = 380;
            this.addChild(this._rewList);
            this._yuanbo = UIFactory.gBitmap(ImagesConst.Yuanbao, 514, 145, this);
            this._gotoChangeBtn = UIFactory.gLoadingButton(ImagesConst.GotoChangeBigBtn_upSkin, 368, 478, 141, 42, this);
            this._gotoChangeBtn.label = "";
            this._gotoTanBaoBtn = UIFactory.gLoadingButton(ImagesConst.ThanksGivingTanBaoBtn_upSkin, 200, 478, 141, 42, this);
            this._gotoTanBaoBtn.label = "";
            this._reBtn = UIFactory.gLoadingButton(ImagesConst.investmentRechargeBtn_upSkin, 540, 135, 141, 43, this);
            this._reBtn.label = "";
            this._des2 = UIFactory.gTextField("" + Language.getString(71939), 36, 269, 630, 90, this, GlobalStyle.textFormatPutong.setColor(16777215));
            this._des2.multiline = true;
            this._des2.wordWrap = true;
            this._secT = new SecTimer(1);
            this._secT.addListener(TimerType.ENTERFRAME, this.timeCk);
            this._secT.start();
            this.timeCk(null);
            this.updateInfo();
            this._gotoTanBaoBtn.configEventListener(MouseEvent.CLICK, this.onOpenTanBao);
            this._gotoChangeBtn.configEventListener(MouseEvent.CLICK, this.onGoTochange);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._secT.stop();
            this._secT = null;
            this._mbg = null;
            this._des = null;
            this._day = null;
            this._hour = null;
            this._min = null;
            this._reNumDes = null;
            this._reNum = null;
            this._itemM = null;
            this._huoYuDes = null;
            this._item1 = null;
            this._item2 = null;
            this._rewList = null;
            this._yuanbo = null;
            this._gotoChangeBtn = null;
            this._gotoTanBaoBtn = null;
            this._reBtn = null;
            this._des2 = null;
            super.disposeImpl(param1);
            return;
        }// end function

        private function genItem() : RebateItem2
        {
            var _loc_1:* = UIFactory.getUICompoment(RebateItem2);
            return _loc_1;
        }// end function

        public function updateInfo() : void
        {
            this.updateItems();
            if (Cache.instance.thanksGiving == null || Cache.instance.thanksGiving.consumInfo == null)
            {
                this._reNum.text = "0";
                return;
            }
            this._reNum.text = "" + Cache.instance.thanksGiving.consumInfo.recharge;
            return;
        }// end function

        private function updateItems() : void
        {
            this._itemM.itemCode = ThanksGivingUtil.huoyuGiftCode;
            this._item1.itemCode = ThanksGivingUtil.wingGiftCode;
            this._item2.itemCode = ThanksGivingUtil.mountGiftCode;
            var _loc_1:* = ThanksGivingUtil.middleGiftCode;
            RewardCfgUtil.updateRwListByGiftCode(_loc_1, this._rewList);
            return;
        }// end function

        private function timeCk(param1:SecTimer) : void
        {
            var _loc_2:Array = null;
            var _loc_3:int = 0;
            _loc_2 = ThanksGivingUtil.getDayCountDownTime();
            _loc_3 = _loc_2[5];
            this._day.text = "" + _loc_2[0];
            this._hour.text = "" + _loc_2[1];
            this._min.text = "" + _loc_2[2];
            if (_loc_3 > 0)
            {
                if (this._secT.running == false)
                {
                    this._secT.start();
                }
            }
            else
            {
                this._secT.stop();
            }
            return;
        }// end function

        private function onGoTochange(event:MouseEvent) : void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.LotteryOpenExchengePanel, 3));
            return;
        }// end function

        private function onOpenTanBao(event:MouseEvent) : void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.LotteryDrawShow));
            return;
        }// end function

    }
}
